<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="10">
            <a-form-model-item label="EC集团客户编码" prop="customernum">
              <a-input placeholder="请输入EC集团客户编码" v-model="queryParam.customernum"></a-input>
            </a-form-model-item>
          </a-col>
          <template v-if="toggleSearchStatus">
          <a-col :md="6" :sm="10">
            <a-form-model-item label="集团客户地址" prop="customerlocation">
              <a-input placeholder="请输入集团客户地址" v-model="queryParam.customerlocation"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :md="6" :sm="10">
            <a-form-model-item label="集团客户名称" prop="customername">
              <a-input placeholder="请输入集团客户名称" v-model="queryParam.customername"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :md="6" :sm="10">
            <a-form-model-item label="客户经理姓名" prop="staffname">
              <a-input placeholder="请输入客户经理姓名" v-model="queryParam.staffname"></a-input>
            </a-form-model-item>
          </a-col>
          </template>

          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :md="6" :sm="10">
            <a-form-model-item label="EC集团客户编码" prop="customernum">
              <a-input placeholder="请输入EC集团客户编码" v-model="queryParam.customernum"></a-input>
            </a-form-model-item>
          </a-col>
          
          <a-col :md="6" :sm="10" >
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('客户信息表')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <biz-org-info-modal ref="modalForm" @ok="modalFormOk"></biz-org-info-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import BizOrgInfoModal from './modules/BizOrgInfoModal'

  export default {
    name: 'BizOrgInfoList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      BizOrgInfoModal
    },
    data () {
      return {
        description: '客户信息表管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'EC集团客户编码',
            align:"center",
            dataIndex: 'customernum',
            sorter: true,
          },
          {
            title:'客户状态1-有效2-冻结，暂停使用3-无效',
            align:"center",
            dataIndex: 'customerstatus',
            sorter: true,
          },
          {
            title:'集团客户名称',
            align:"center",
            dataIndex: 'customername',
            sorter: true,
          },
          {
            title:'集团客户归属省代码',
            align:"center",
            dataIndex: 'companyid',
            sorter: true,
          },
          {
            title:'集团客户归属地市编码',
            align:"center",
            dataIndex: 'location'
          },
          {
            title:'集团客户地址',
            align:"center",
            dataIndex: 'customerlocation'
          },
          {
            title:'客户来源 hedun-和盾 bboss-BBOSS probation-试用表单',
            align:"center",
            dataIndex: 'customersource'
          },
          {
            title:'行业类别参考《一级BBOSS系统通用枚举值规范v1.2》的行业编码',
            align:"center",
            dataIndex: 'industryid'
          },
          {
            title:'客户经理姓名',
            align:"center",
            dataIndex: 'staffname'
          },
          {
            title:'客户经理电话',
            align:"center",
            dataIndex: 'staffphone'
          },
          {
            title:'客户经理工号',
            align:"center",
            dataIndex: 'staffnumber'
          },
          {
            title:'客户服务等级 1-金牌级 2-银牌级 3-铜牌级 4-标准级',
            align:"center",
            dataIndex: 'customerservlevel'
          },
          {
            title:'客户联系电话【只允许手机号码】',
            align:"center",
            dataIndex: 'customerphone'
          },
          {
            title:'客户联系邮件',
            align:"center",
            dataIndex: 'costomeremail'
          },
          {
            title:'告警通知方式1-短信2-邮件3-短信+邮件4-电话',
            align:"center",
            dataIndex: 'costomercontact'
          },
          {
            title:'集中抗D同步标记0-未同步（默认）5-同步中（插入同步任务表）1-同步确认中3-同步成功（正常状态）4-同步失败2-已修改，未同步（WEB端修改后）',
            align:"center",
            dataIndex: 'syncflag'
          },
          {
            title:'同步返回信息',
            align:"center",
            dataIndex: 'syncinfo'
          },
          {
            title:'负责人',
            align:"center",
            dataIndex: 'header'
          },
          {
            title:'创建时间',
            align:"center",
            dataIndex: 'createdatetime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'最后修改时间',
            align:"center",
            dataIndex: 'updatedatetime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'0 - 正式，1 - 试用',
            align:"center",
            dataIndex: 'customertype'
          },
          {
            title:'开通状态 1、未开通，待补齐企业信息；2、已开通',
            align:"center",
            dataIndex: 'openstatus'
          },
          {
            title:'真实客户编码',
            align:"center",
            dataIndex: 'realcustomernum'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/bizorginfo/bizOrgInfo/list",
          delete: "/bizorginfo/bizOrgInfo/delete",
          deleteBatch: "/bizorginfo/bizOrgInfo/deleteBatch",
          exportXlsUrl: "/bizorginfo/bizOrgInfo/exportXls",
          importExcelUrl: "bizorginfo/bizOrgInfo/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'customernum',text:'EC集团客户编码'})
        fieldList.push({type:'string',value:'customerstatus',text:'客户状态1-有效2-冻结，暂停使用3-无效'})
        fieldList.push({type:'string',value:'customername',text:'集团客户名称'})
        fieldList.push({type:'string',value:'companyid',text:'集团客户归属省代码'})
        fieldList.push({type:'string',value:'location',text:'集团客户归属地市编码'})
        fieldList.push({type:'string',value:'customerlocation',text:'集团客户地址'})
        fieldList.push({type:'string',value:'customersource',text:'客户来源 hedun-和盾 bboss-BBOSS probation-试用表单'})
        fieldList.push({type:'string',value:'industryid',text:'行业类别参考《一级BBOSS系统通用枚举值规范v1.2》的行业编码'})
        fieldList.push({type:'string',value:'staffname',text:'客户经理姓名'})
        fieldList.push({type:'string',value:'staffphone',text:'客户经理电话'})
        fieldList.push({type:'string',value:'staffnumber',text:'客户经理工号'})
        fieldList.push({type:'string',value:'customerservlevel',text:'客户服务等级 1-金牌级 2-银牌级 3-铜牌级 4-标准级'})
        fieldList.push({type:'string',value:'customerphone',text:'客户联系电话【只允许手机号码】'})
        fieldList.push({type:'string',value:'costomeremail',text:'客户联系邮件'})
        fieldList.push({type:'string',value:'costomercontact',text:'告警通知方式1-短信2-邮件3-短信+邮件4-电话'})
        fieldList.push({type:'string',value:'syncflag',text:'集中抗D同步标记0-未同步（默认）5-同步中（插入同步任务表）1-同步确认中3-同步成功（正常状态）4-同步失败2-已修改，未同步（WEB端修改后）'})
        fieldList.push({type:'string',value:'syncinfo',text:'同步返回信息'})
        fieldList.push({type:'string',value:'header',text:'负责人'})
        fieldList.push({type:'date',value:'createdatetime',text:'创建时间'})
        fieldList.push({type:'date',value:'updatedatetime',text:'最后修改时间'})
        fieldList.push({type:'string',value:'customertype',text:'0 - 正式，1 - 试用'})
        fieldList.push({type:'int',value:'openstatus',text:'开通状态 1、未开通，待补齐企业信息；2、已开通'})
        fieldList.push({type:'string',value:'realcustomernum',text:'真实客户编码'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>